package strategyDesignPattern

class Share {

    private val strategyList = ArrayList<DealContext>()

    //初始化执行策略，新增删除在此处修改即可
    init {
        strategyList.add(DealContext(ShareChannel.SINA, SinaShare()))
        strategyList.add(DealContext(ShareChannel.WE_CHART, WeChartShare()))
    }

    fun shareOptions(type: ShareChannel) {
        //寻找执行的策略
        strategyList.forEach {
            if (it.options(type)) {
                it.getDeal().dealMethod(type)
            }
        }
    }
}